vector does not erase content correctly (infite amount run of copy asignment operator untill crash [BEX])?
Posted
by
Gam Erix
on Stack Overflow
See other posts from Stack Overflow
or by Gam Erix
Published on 2012-12-15T17:00:39Z
Indexed on
2012/12/15
17:03 UTC
Read the original article
Hit count: 158
Well my problem is that after I want to "unload" loaded DLL's the copy assignmnent operator is called an unlimited amount of times until crash.
The code from which I remove the vector data looks like this:
void UnloadPlugins()
{
dbg(("[DBG]UnloadPlugins()"));
for(std::vector<DLLInfo>::iterator it = plugins.begin(); it != plugins.end(); ++it)
{
plugins.erase(it);
}
dbg(("[DBG]UnloadPlugins()::Done"));
}
however "[DBG]UnloadPlugins()::Done" gets never printed.
this is my copy assignmnent operator:
// 2. copy assignment operator
DLLInfo& operator=(const DLLInfo& that)
{
dbg(("[DBG]Start-DLLInfo& operator=(const DLLInfo& that)"));
Instance = that.Instance;//hinstance
dbg(("[DBG]DLLInfo 1"));
//Identifier.assign(that.Identifier);//string
dbg(("[DBG]DLLInfo 2"));
IsAMX = that.IsAMX;//integer
dbg(("[DBG]DLLInfo 3"));
dwSupportFlags = that.dwSupportFlags;//integer
dbg(("[DBG]DLLInfo 4"));
Load = that.Load;//integer
dbg(("[DBG]DLLInfo 5"));
Unload = that.Unload;//integer
dbg(("[DBG]DLLInfo 6"));
Supports = that.Supports;//integer
dbg(("[DBG]DLLInfo 7"));
ProcessTick = that.ProcessTick;//integer
dbg(("[DBG]DLLInfo 8"));
AmxLoad = that.AmxLoad;//integer
dbg(("[DBG]DLLInfo 9"));
AmxUnload = that.AmxUnload;//integer
dbg(("[DBG]DLLInfo 10"));
UseDestructor = that.UseDestructor;//bool
dbg(("[DBG]DLLInfo 11"));
KeyboardHit = that.KeyboardHit;//integer
dbg(("[DBG]End-DLLInfo& operator=(const DLLInfo& that)"));
return *this;
}
So the log looks like:
[17:50:50] [DBG]UnloadPlugins()
[17:50:50] [DBG]~DLLInfo
[17:50:50] [DBG]~DLLInfo::if(this->UseDestructor) passed
[17:50:50] [DBG]~DLLInfo::if(this->UseDestructor)::if(this->Unload != NULL && this->IsAMX) passed
[17:50:50] [DBG]~DLLInfo::end
[17:50:50] [DBG]Start-DLLInfo& operator=(const DLLInfo& that)
[17:50:50] [DBG]DLLInfo 1
[17:50:50] [DBG]DLLInfo 2
[17:50:50] [DBG]DLLInfo 3
[17:50:50] [DBG]DLLInfo 4
[17:50:50] [DBG]DLLInfo 5
[17:50:50] [DBG]DLLInfo 6
[17:50:50] [DBG]DLLInfo 7
[17:50:50] [DBG]DLLInfo 8
[17:50:50] [DBG]DLLInfo 9
[17:50:50] [DBG]DLLInfo 10
[17:50:50] [DBG]DLLInfo 11
[17:50:50] [DBG]End-DLLInfo& operator=(const DLLInfo& that)
[17:50:50] [DBG]Start-DLLInfo& operator=(const DLLInfo& that)
...
[17:50:50] [DBG]End-DLLInfo& operator=(const DLLInfo& that)
...repeat until crash
What could the problem be?
© Stack Overflow or respective owner